import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StaffVO, StaffForm, StaffQuery } from '@/api/trace/staff/types';

/**
 * 查询溯源人员列表
 * @param query
 * @returns {*}
 */

export const listStaff = (query?: StaffQuery): AxiosPromise<StaffVO[]> => {
  return request({
    url: '/trace/staff/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询溯源人员详细
 * @param staffId
 */
export const getStaff = (staffId: string | number): AxiosPromise<StaffVO> => {
  return request({
    url: '/trace/staff/' + staffId,
    method: 'get'
  });
};

/**
 * 新增溯源人员
 * @param data
 */
export const addStaff = (data: StaffForm) => {
  return request({
    url: '/trace/staff',
    method: 'post',
    data: data
  });
};

/**
 * 修改溯源人员
 * @param data
 */
export const updateStaff = (data: StaffForm) => {
  return request({
    url: '/trace/staff',
    method: 'put',
    data: data
  });
};

/**
 * 删除溯源人员
 * @param staffId
 */
export const delStaff = (staffId: string | number | Array<string | number>) => {
  return request({
    url: '/trace/staff/' + staffId,
    method: 'delete'
  });
};
